<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app">
    <el-button @click="handlerBuy">购买商品</el-button>
</div>
</body>
<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    new Vue({
        el: '#app',
        data: {
            token: null,
            Logintoken: null
        },
        methods: {
            // 购买商品
            handlerBuy(){
                axios.get("/order/buy/1",{headers: {"token":this.token,"Logintoken":this.Logintoken}}).then(res => {
                    if(res.data.code == 200){
                        // 响应成功
                        this.$message.success(res.data.message);
                    }else{
                        // 响应失败
                        this.$message.error(res.data.message);
                    }
                });
            }
        },
        created(){
            axios.get("/order/create/token").then(res =>{
                this.token=res.data.data;
            });



        }
    })
</script>
</html>
